package org.wmq.skyserver.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wmq.skycommon.WebSocket.WebSocketServer;
import org.wmq.skycommon.exception.NotExistsError;
import org.wmq.skycommon.pojo.DTO.OrderSubmitDTO;
import org.wmq.skycommon.pojo.VO.OrderSubmitVO;
import org.wmq.skycommon.pojo.entity.Order;
import org.wmq.skyserver.mapper.OrderDetailMapper;
import org.wmq.skyserver.mapper.OrderMapper;
import org.wmq.skyserver.service.OrderService;

import java.util.HashMap;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private OrderDetailMapper orderDetailMapper;
    @Autowired
    private WebSocketServer webSocketServer;

    @Override
    public OrderSubmitVO submitOrder(OrderSubmitDTO orderSubmitDTO) {
        this.orderMapper.insert();
        return null;
    }

    @Override
    public void reminder(Integer orderId) {
        Order order = this.orderMapper.getbyId(orderId);
        if (order == null){
            throw new NotExistsError("order is not exists");
        }
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("type",2);
        map.put("orderId",orderId);
        map.put("content","");
        this.webSocketServer.sendToAllClient("");
    }
}
